package com.pajk.user.exception;

import net.pocrd.entity.ReturnCode;

/**
 * Base exception for all login service exceptions.
 *
 * NOTE: the exception code uses those defined in API GATEWAY
 * 
 */
public class LoginServiceException extends RuntimeException {

    protected int exceptionCode = ReturnCode._C_UNKNOWN_ERROR;

    public int getExceptionCode() {
        return exceptionCode;
    }

    public LoginServiceException() {
        super();
    }

    public LoginServiceException(String message) {
        super(message);
    }

    public LoginServiceException(String message, int exceptionCode) {
        super(message);
        this.exceptionCode = exceptionCode;
    }

    public LoginServiceException(String message, Throwable cause) {
        super(message, cause);
    }

    public LoginServiceException(String message, Throwable cause, int exceptionCode) {
        super(message, cause);
        this.exceptionCode = exceptionCode;
    }

    public LoginServiceException(Throwable cause) {
        super(cause);
    }

    public LoginServiceException(Throwable cause, int exceptionCode) {
        super(cause);
        this.exceptionCode = exceptionCode;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("LoginServiceException{");
        sb.append("exceptionCode=").append(exceptionCode);
        sb.append(", msg=").append(ReturnCode.findCode(exceptionCode).getDesc());
        sb.append('}');
        return sb.toString();
    }
}
